package com.bdqn.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bdqn.mapper.RightMapper;
import com.bdqn.pojo.Right;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

/**
 * RightServiceImpl
 *
 * @author LILIBO
 * @since 2023-12-20
 */
@Service
public class RightServiceImpl extends ServiceImpl<RightMapper, Right> implements RightService {

    @Resource
    private RightMapper rightMapper;

    /**
     * 获得所有权限列表
     *
     * @return
     */
    @Override
    @Cacheable(value = "right", key = "'getAll'", unless = "#result==null")
    public List<Right> getAllRight() {
        return rightMapper.getAllRight();
    }

    /**
     * 根据角色获得权限列表
     *
     * @return
     */
    @Override
    public Set<Right> getRightByRoleId(Long roleId) {
        return rightMapper.getRightByRoleId(roleId);
    }

}
